package com.oauth.resource.feign;

import com.oauth.common.api.BaseResponse;
import com.oauth.resource.vo.UserGetDetailVO;
import com.secure.annotation.ApiSecure;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author duchao
 */
@FeignClient(name = "oauth-authorization",path = "oauth")
public interface OauthFeign {

    @ApiSecure
    @RequestMapping(value = "xWwwFormUrlencoded",method = RequestMethod.POST,consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    BaseResponse<Map<String, Object>> xWwwFormUrlencoded(@RequestParam("id") Integer id,@RequestParam("name") String name);

    @ApiSecure
    @RequestMapping(value = "xWwwFormUrlencoded2",method = {RequestMethod.GET},consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    BaseResponse<String> xWwwFormUrlencoded2(@RequestBody String content);

    @ApiSecure
    @PostMapping(value = "json1",consumes = MediaType.APPLICATION_JSON_VALUE)
    BaseResponse<UserGetDetailVO> json1(@RequestBody UserGetDetailVO vo);

    @ApiSecure
    @PostMapping(value = "json2",consumes = MediaType.APPLICATION_JSON_VALUE)
    BaseResponse<String> json2(@RequestBody String content);

    @ApiSecure
    @PostMapping(value = "text1",consumes = MediaType.TEXT_PLAIN_VALUE)
    BaseResponse<String> text1(@RequestBody String content);

    @ApiSecure
    @PostMapping(value = "form1",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    BaseResponse<Map<String, Object>> form1(@RequestParam("id") Integer id,@RequestParam("name") String name);

    @ApiSecure
    @PostMapping(value = "form2")
    BaseResponse<Map<String, Object>> form2(@RequestParam("id") Integer id,@RequestParam("name") String name);

    /**
     * 入参是对象的编码器会拦截
     * @param vo
     * @return
     */
    @PostMapping(value = "query")
    BaseResponse<Map<String, Object>> query(UserGetDetailVO vo);
}
